package com.redis;

import com.springboot.springbootredis.SpringbootRedisClusterApplication;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.test.context.junit4.SpringRunner;
import redis.clients.jedis.JedisCluster;

@RunWith(SpringRunner.class)
@SpringBootTest(classes = SpringbootRedisClusterApplication.class)
@Slf4j
public class Cluster {

    @Autowired
    private RedisTemplate<String, String> redisTemplate;

    @Autowired
    private JedisCluster jedisCluster;

    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    @Test
    public void test(){

        this.jedisCluster.set("name", "hello redis cluster");


        String name1 = redisTemplate.opsForValue().get("name");

        String name2 = stringRedisTemplate.opsForValue().get("name");

        String name3 = this.jedisCluster.get("name");

        log.info("单机redisTemplate：{}",name1);
        log.info("stringRedisTemplate：{}",name2);
        log.info("jedisCluster：{}",name3);
    }

}
